home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / game / shoot / Heretic.lha / Heretic / c2p / c2p_noe.s < prev    next >
Text File  |  1999-02-15  |  5KB  |  296 lines

  1. ;c2p by Noe / Venus Art 5 pass cpu,for 040 cpu
  2.  
  3. ;3 functions must be provided:
  4. ; C2P_Init
  5. ; C2P_CleanUp
  6. ; C2P_Do
  7. ;
  8.  
  9. ; this in plugin module, cannot be started as any other program
  10.         moveq   #0,d0
  11.         rts
  12.  
  13. ; Do not change this:
  14.  
  15.         dc.b    "C2P",0                 ;module id, MUST BE 'C2P'!!!
  16.         dc.l    C2P_Init                ; pointer to init routine
  17.         dc.l    C2P_CleanUp             ;pointer to de-init routine
  18.         dc.l    C2P_Do                  ;pointer to main c2p function
  19.         dc.l    0
  20.  
  21.         cnop    0,4
  22. C2P_Init
  23. ; Here you can do all initializations needed by yours c2p
  24. ; In:
  25. ;  d0.l SCREENWIDTH
  26. ;  d1.l SCREENHEIGHT
  27. ; Out:
  28. ;  0  - something went wrong
  29. ;  1  - Init ok, C2P supports every resolution
  30. ;  2  - Init ok, C2P supports only 320x200 resolution.
  31.  
  32.         moveq   #2,d0
  33.         rts
  34.  
  35.         cnop    0,4
  36. C2P_CleanUp
  37. ; Here you should clean all things you have made in C2P_Init 
  38. ; (like freeing memory, etc.)
  39. ; This module does nothing here... ;)
  40.         rts
  41.  
  42. ;some usefull macros
  43.  
  44. MOVE_HI_nBITS2    MACRO    ; data1, data2
  45.             ; data3, data4
  46.             ; mask, shift
  47.         and.l    \5,\1
  48.         and.l    \5,\2
  49.         and.l    \5,\3
  50.         and.l    \5,\4
  51.         lsr.l    #\6,\2
  52.         lsr.l    #\6,\4
  53.         or.l    \2,\1
  54.         or.l    \4,\3
  55.         ENDM
  56.  
  57. MERGE_nBITS2    MACRO    ; data1, data2, temp12,
  58.             ; data3, data4, temp34,
  59.             ; mask, shift
  60.         move.l    \2,\3            ; 2
  61.         move.l    \5,\6            ; 2
  62.         lsr.l    #\8,\3            ; 4
  63.         lsr.l    #\8,\6            ; 4
  64.         eor.l    \1,\3            ; 2
  65.         eor.l    \4,\6            ; 2
  66.         and.l    \7,\3            ; 2
  67.         and.l    \7,\6            ; 2
  68.         eor.l    \3,\1            ; 2
  69.         eor.l    \6,\4            ; 2
  70.     IFEQ    \8-1
  71.         add.l    \3,\3            ; 2
  72.         add.l    \6,\6            ; 2
  73.     ELSE
  74.         lsl.l    #\8,\3            ; 4
  75.         lsl.l    #\8,\6            ; 4
  76.     ENDC
  77.         eor.l    \3,\2            ; 2
  78.         eor.l    \6,\5            ; 2
  79.         ENDM                ; = 32/36
  80.  
  81. MERGE_WORD2    MACRO    ; data1, data2, temp12
  82.             ; data3, data4, temp34
  83.         move.l    \2,\3            ; 2
  84.         move.l    \5,\6            ; 2
  85.         move.w    \1,\2            ; 2
  86.         move.w    \4,\5            ; 2
  87.         swap    \2            ; 4
  88.         swap    \5            ; 4
  89.         move.w    \2,\1            ; 2
  90.         move.w    \5,\4            ; 2
  91.         move.w    \3,\2            ; 2
  92.         move.w    \6,\5            ; 2
  93.         ENDM                ; = 24
  94.  
  95. MOVE_LO_nBITS2    MACRO    ; data1, data2
  96.             ; data3, data4
  97.             ; mask, shift
  98.         and.l    \5,\1
  99.         and.l    \5,\2
  100.         and.l    \5,\3
  101.         and.l    \5,\4
  102.     IFEQ    \6-1
  103.         add.l    \2,\1
  104.         add.l    \4,\3
  105.     ELSE
  106.         lsl.l    #\6,\1
  107.         lsl.l    #\6,\3
  108.     ENDC
  109.         or.l    \2,\1
  110.         or.l    \4,\3
  111.         ENDM
  112.  
  113. ;hardcoded screen resolution.
  114. ;It is possible to patch this routine to use other resolution than 320x200
  115. ; but it requires selfmodyfing code.
  116.  
  117. WIDTH        EQU    320
  118. HEIGHT        EQU    200
  119. WIDTH_B        EQU    WIDTH>>3
  120.  
  121.         cnop    0,4
  122. C2P_Do
  123. ;Core c2p routine.
  124. ;
  125. ; In:
  126. ;  a0.l - pointer to chunky in fastmem. (SCREENWIDTH*SCREENHEIGHT)
  127. ;  a1.l - pointer to INTERLEAVED bitplanes
  128. ; Out:
  129. ;  None
  130.         movem.l    d2-d7/a2-a6,-(sp)
  131.  
  132.         move.l    a1,-(sp)
  133.         move.l    a0,-(sp)
  134.  
  135.         lea    (a1,(4*WIDTH_B).w),a1
  136.         lea    (a0,(WIDTH*HEIGHT).l),a2
  137.  
  138.         move.l    #$00ff00ff,a6
  139.  
  140.         move.w    #WIDTH/32,d7
  141.  
  142.         move.l    #$f0f0f0f0,d6
  143.  
  144.         movem.l    (a0)+,d0/d1/d2/d3
  145.  
  146.         MOVE_HI_nBITS2    d0,d1,d2,d3,d6,4
  147.  
  148.         movem.l    (a0)+,d1/d3/d4/d5
  149.  
  150.         MOVE_HI_nBITS2    d1,d3,d4,d5,d6,4
  151.  
  152.         move.l    a6,d6
  153.         MERGE_nBITS2    d0,d2,d3,d1,d4,d5,d6,8
  154.  
  155.         MERGE_WORD2    d0,d1,d3,d2,d4,d5
  156.  
  157.         move.l    #$33333333,d6
  158.         MERGE_nBITS2    d0,d1,d3,d2,d4,d5,d6,2
  159.  
  160.         move.l    #$55555555,d6
  161.         MERGE_nBITS2    d0,d2,d3,d1,d4,d5,d6,1
  162.  
  163.         move.l    d0,(a1,(3*WIDTH_B).w)
  164.         move.l    d2,a3
  165.         move.l    d1,a4
  166.         move.l    d4,a5
  167.  
  168. C2P_FI_320x200C_loop1
  169.         move.l    #$f0f0f0f0,d6
  170.  
  171.         movem.l    (a0)+,d0/d1/d2/d3
  172.  
  173.         MOVE_HI_nBITS2    d0,d1,d2,d3,d6,4
  174.  
  175.         movem.l    (a0)+,d1/d3/d4/d5
  176.  
  177.         move.l    a3,(a1,(2*WIDTH_B).w)
  178.  
  179.         MOVE_HI_nBITS2    d1,d3,d4,d5,d6,4
  180.  
  181.         move.l    a6,d6
  182.         MERGE_nBITS2    d0,d2,d3,d1,d4,d5,d6,8
  183.  
  184.         move.l    a4,(a1,(1*WIDTH_B).w)
  185.  
  186.         MERGE_WORD2    d0,d1,d3,d2,d4,d5
  187.  
  188.         move.l    #$33333333,d6
  189.         MERGE_nBITS2    d0,d1,d3,d2,d4,d5,d6,2
  190.  
  191.         move.l    a5,(a1)+
  192.  
  193.         subq.w    #1,d7
  194.         bne.b    C2P_FI_320x200C_1
  195.         lea    (a1,(7*WIDTH_B).w),a1
  196.         move.w    #WIDTH/32,d7
  197. C2P_FI_320x200C_1
  198.  
  199.         move.l    #$55555555,d6
  200.         MERGE_nBITS2    d0,d2,d3,d1,d4,d5,d6,1
  201.  
  202.         move.l    d2,a3
  203.         move.l    d1,a4
  204.         move.l    d4,a5
  205.         move.l    d0,(a1,(3*WIDTH_B).w)
  206.  
  207.         cmpa.l    a2,a0
  208.         bne.w    C2P_FI_320x200C_loop1
  209.  
  210.         move.l    (sp)+,a0
  211.  
  212.         move.w    #WIDTH/32,d7
  213.  
  214.         move.l    #$0f0f0f0f,d6
  215.  
  216.         movem.l    (a0)+,d0/d1/d2/d3
  217.  
  218.         MOVE_LO_nBITS2    d0,d1,d2,d3,d6,4
  219.  
  220.         movem.l    (a0)+,d1/d3/d4/d5
  221.  
  222.         move.l    a3,(a1,(2*WIDTH_B).w)
  223.  
  224.         MOVE_LO_nBITS2    d1,d3,d4,d5,d6,4
  225.  
  226.         move.l    a6,d6
  227.         MERGE_nBITS2    d0,d2,d3,d1,d4,d5,d6,8
  228.  
  229.         move.l    a4,(a1,(1*WIDTH_B).w)
  230.  
  231.         MERGE_WORD2    d0,d1,d3,d2,d4,d5
  232.  
  233.         move.l    #$33333333,d6
  234.         MERGE_nBITS2    d0,d1,d3,d2,d4,d5,d6,2
  235.  
  236.         move.l    a5,(a1)
  237.  
  238.         move.l    #$55555555,d6
  239.         MERGE_nBITS2    d0,d2,d3,d1,d4,d5,d6,1
  240.  
  241.         move.l    (sp)+,a1
  242.  
  243.         move.l    d0,(a1,(3*WIDTH_B).w)
  244.         move.l    d2,a3
  245.         move.l    d1,a4
  246.         move.l    d4,a5
  247.  
  248. C2P_FI_320x200C_loop2
  249.         move.l    #$0f0f0f0f,d6
  250.  
  251.         movem.l    (a0)+,d0/d1/d2/d3
  252.  
  253.         MOVE_LO_nBITS2    d0,d1,d2,d3,d6,4
  254.  
  255.         movem.l    (a0)+,d1/d3/d4/d5
  256.  
  257.         move.l    a3,(a1,(2*WIDTH_B).w)
  258.  
  259.         MOVE_LO_nBITS2    d1,d3,d4,d5,d6,4
  260.  
  261.         move.l    a6,d6
  262.         MERGE_nBITS2    d0,d2,d3,d1,d4,d5,d6,8
  263.  
  264.         move.l    a4,(a1,(1*WIDTH_B).w)
  265.  
  266.         MERGE_WORD2    d0,d1,d3,d2,d4,d5
  267.  
  268.         move.l    #$33333333,d6
  269.         MERGE_nBITS2    d0,d1,d3,d2,d4,d5,d6,2
  270.  
  271.         move.l    a5,(a1)+
  272.  
  273.         subq.w    #1,d7
  274.         bne.b    C2P_FI_320x200C_2
  275.         lea    (a1,(7*WIDTH_B).w),a1
  276.         move.w    #WIDTH/32,d7
  277. C2P_FI_320x200C_2
  278.  
  279.         move.l    #$55555555,d6
  280.         MERGE_nBITS2    d0,d2,d3,d1,d4,d5,d6,1
  281.  
  282.         move.l    d2,a3
  283.         move.l    d1,a4
  284.         move.l    d4,a5
  285.         move.l    d0,(a1,(3*WIDTH_B).w)
  286.  
  287.         cmpa.l    a2,a0
  288.         bne.w    C2P_FI_320x200C_loop2
  289.  
  290.         move.l    a3,(a1,(2*WIDTH_B).w)
  291.         move.l    a4,(a1,(1*WIDTH_B).w)
  292.         move.l    a5,(a1)
  293.  
  294.         movem.l    (sp)+,d2-d7/a2-a6
  295.                 rts
  296.